<template>
    <div class="box-container">
        <div class="box" v-for="item in props.spotListValue" :key="item.id">
            <img :src="item.thumbnail">
            <div class="content">
                <h3>{{ item.spotName }}</h3>
                <p>{{ item.summary }}</p>
                <a class="btn" @click="handleclick(item.id)">read more</a>
            </div>
        </div>
    </div>
</template>


<script setup>
import { useRouter } from 'vue-router';
import { updateSpotViewCountAPI } from '@/api';

const router = useRouter()
const props = defineProps({
    spotListValue: {
        type: Array,
        default: []
    },
})

const handleclick = async (val) => {
    await updateSpotViewCountAPI(val)
    router.push({
        path: "/layout/spotdetail",
        query: {
            spotId: val
        }
    }).catch(err => { })
}

</script>


<style lang="scss" scoped>
.container .box-container {
    margin-top: 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(32rem, 1fr));
    gap: 2rem;

    .box {
        text-align: center;
        overflow: hidden;
        height: 30rem;
        flex: 1 1 30rem;
        border: 1px solid rgba(255, 255, 255, 0.7);
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.2);
        position: relative;
    }

    .box img {
        height: 100%;
        width: 100%;
        object-fit: cover;
    }

    .box .content {
        position: absolute;
        top: -100%;
        left: 0;
        height: 100%;
        width: 100%;
        background: rgba(0, 0, 0, 0.7);
        padding: 3rem 2rem;
    }

    .box:hover .content {
        top: 0;
    }

    .content h3 {
        font-size: 2.5rem;
        color: orange;
    }

    .content p {
        font-size: 1.4rem;
        margin: 1rem 0;
        color: #fff;
        line-height: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 5;
        line-clamp: 5;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .content .btn {
        border: .2rem solid orange;
        display: inline-block;
        cursor: pointer;
        margin-top: 1rem;
        padding: 1rem 2rem;
        background: none;
        font-size: 1.6rem;
        color: orange;
    }

    .content .btn:hover {
        border-color: #fff;
        background: white;
        color: #222;
    }
}
</style>